package 集合.Collection.Collection中的常用方法.contains深入.Test02;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class ContainsTest02 {
    public static void main(String[] args) {
        Collection c = new ArrayList();
        User u1 = new User("kkkkk");
        c.add(u1);
        User u2 = new User("kkkkk");
        System.out.println(c.contains(u2));
        Iterator it = c.iterator();
        //发生异常，在获取迭代器之后加了一个元素改变了集合的结构。
        c.add(1);
        while(it.hasNext()){
            Object obj = it.next();
        }

    }
}
